﻿@using System.Text;
@using EC_ASS.Models;

<!--Loading shopping cart-->

@model EC_ASS.Models.BigModel
<header>
    <div class="container" >
        <h1 class="logo">
            <a href="/Home/Index" >
                <img alt="Logo" src="@Url.Content("~/img/logo.png")" />
            </a>
        </h1>
        <nav id="menuTop">
            <ul class="nav nav-pills nav-top">
                @if (Session["CUST"] == null)
                {
                    @*<li><fb:login-button autologoutlink="true" perms="read_friendlists, create_event, email, publish_stream"></fb:login-button></li>*@
                    <li >
                        <a href="#loginModal" data-toggle="modal">| Đăng nhập |</a>
                    </li>
                    <li>
                        <a href="/Account/Register">| Đăng kí |</a>
                    </li>
                }
                else
                {
                    Customer cus = (Customer)Session["CUST"];
                    <li class="dropdown">
                        <a id="drop1" href="#" class="dropdown-toggle" data-toggle="dropdown">Chào, @cus.Name <b class="caret"></b></a>
                        <ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
                            <li role="presentation">
                                <a href="/Account/Index">Xem thông tin</a>
                            </li>
                            <li role="presentation"><a role="menuitem" tabindex="-1" href="/Account/Logout">Thoát</a></li>
                        </ul>
                    </li>
                }
                <li class="dropdown" id="shoppingCart">                   
                    <script>
                        function getCart() {
                            $('#shoppingCart').load('@Url.Action("_ShoppingCart", "Product")');
                        }
                    </script>
                </li>
                <li>
                    <form class="form-search" id="searchForm" action="/Home/Search" method="get">
                        <div class="control-group">
                            <input type="text" name="key" id="key" placeholder="Tìm kiếm ...">
                            <select name="price" class="span2">
                                <option value="0">Giá</option>
                                <option value="1">< 100.000 </option>
                                <option value="2">101.000 - 300.000</option>
                                <option value="3">> 300.000 </option>
                            </select>
                            <button class="btn" type="submit"><i class="icon-search"></i></button>
                        </div>
                    </form>
                </li>
            </ul>
        </nav>
        <div class="social-icons">
            <ul class="social-icons">
                <li class="facebook"><a href="http://www.facebook.com/exam.us" target="_blank" title="Facebook">Facebook</a></li>
                <li class="googleplus"><a href="http://www.plus.google.com/exam.us" target="_blank" title="Google+">Google+</a></li>
                <li class="yahoo"><a href="http://www.plus.google.com/exam.us" target="_blank" title="Yà Hú">Yà Hú</a></li>
            </ul>
        </div>
        <nav>
            <ul class="nav nav-pills nav-main" id="mainMenu">
                <li class="dropdown">
                    <a class="dropdown-toggle" href="#">Home
									<i class="icon-angle-down"></i>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a href="@Request.Url.ToString().Replace("http://locmx-mshop", "https://locmx-mshop:44300")">Duyệt trang an toàn</a></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a class="dropdown-toggle" href="#">Áo Nam
									<i class="icon-angle-down"></i>
                    </a>
                    <ul class="dropdown-menu">
                        @foreach (var item in Model.PA)
                        {
                            <li><a href="/Category/@item.ID/@ToUrlName(@item.Description.ToString()).Trim().Replace(" ", "-")/ViewAll">@item.Name</a></li> 
                        }
                    </ul>
                </li>
                <li class="dropdown">
                    <a class="dropdown-toggle" href="#">Quần Nam
									<i class="icon-angle-down"></i>
                    </a>
                    <ul class="dropdown-menu">
                        @foreach (var item in Model.PQ)
                        {
                            <li><a href="/Category/@item.ID/@ToUrlName(@item.Description.ToString()).Trim().Replace(" ", "-")/ViewAll">@item.Name</a></li> 
                        }
                    </ul>
                </li>
                <li class="dropdown">
                    <a class="dropdown-toggle" href="#">Giày Dép
									<i class="icon-angle-down"></i>
                    </a>
                    <ul class="dropdown-menu">
                        @foreach (var item in Model.PG)
                        {
                            <li><a href="/Category/@item.ID/@ToUrlName(@item.Description.ToString()).Trim().Replace(" ", "-")/ViewAll">@item.Name</a></li> 
                        }
                    </ul>
                </li>
                <li class="dropdown">
                    <a class="dropdown-toggle" href="#">Phụ Kiện
									<i class="icon-angle-down"></i>
                    </a>
                    <ul class="dropdown-menu">
                        @foreach (var item in Model.PK)
                        {
                            <li><a href="/Category/@item.ID/@ToUrlName(@item.Description.ToString()).Trim().Replace(" ", "-")/ViewAll">@item.Name</a></li> 
                        }
                    </ul>
                </li>
            </ul>
        </nav>
    </div>
</header>

@functions {
    string ToUrlName(string name)
    {
        string stFormD = name.Normalize(NormalizationForm.FormD);
        StringBuilder sb = new StringBuilder();
        for (int ich = 0; ich < stFormD.Length; ich++)
        {
            System.Globalization.UnicodeCategory uc = System.Globalization.CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]);
            if (uc != System.Globalization.UnicodeCategory.NonSpacingMark)
            {
                sb.Append(stFormD[ich]);
            }
        }
        sb = sb.Replace('Đ', 'D');
        sb = sb.Replace('đ', 'd');
        return (sb.ToString().Normalize(NormalizationForm.FormD).ToUpperInvariant().Trim().Replace(" ", "-"));
    }
}
